using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Decisions.HL7.Message;
using DecisionsFramework;

namespace Decisions.HL7.Message
{
    public class ConditionCodeAttribute:RuleAttribute
    {
        private Dictionary<HL7Version, string[]> validVersionCodes = new Dictionary<HL7Version, string[]>();
        private Dictionary<HL7Version, string[]> validVersionDescriptions = new Dictionary<HL7Version, string[]>();
        private Dictionary<HL7Version, HL7TableType> tableVersionTypes = new Dictionary<HL7Version, HL7TableType>();

        public ConditionCodeAttribute()
        {
            // init the values for table version types
						tableVersionTypes[HL7Version.v23] = HL7TableType.User;
						tableVersionTypes[HL7Version.v231] = HL7TableType.User;
						tableVersionTypes[HL7Version.v24] = HL7TableType.User;
						tableVersionTypes[HL7Version.v25] = HL7TableType.User;
						tableVersionTypes[HL7Version.v251] = HL7TableType.User;
						tableVersionTypes[HL7Version.v26] = HL7TableType.User;
						tableVersionTypes[HL7Version.v27] = HL7TableType.User;
			
            
			// init the values for version codes
						validVersionCodes[HL7Version.v23] = new string[]{""};
						validVersionCodes[HL7Version.v231] = new string[]{"01","02","03","04","05","06","07","08","09","10","11","12 ... 16","18","19","20","21","26","27","28","29","31","32","33","34","36","37","38","39","40","41","46","48","55","56","57","60","61","62","66","67","68","70","71","72","73","74","75","76","77","78","79","80"};
						validVersionCodes[HL7Version.v24] = new string[]{"01","02","03","04","05","06","07","08","09","10","11","12 ... 16","18","19","20","21","26","27","28","29","31","32","33","34","36","37","38","39","40","41","46","48","55","56","57","60","61","62","66","67","68","70","71","72","73","74","75","76","77","78","79","80"};
						validVersionCodes[HL7Version.v25] = new string[]{""};
						validVersionCodes[HL7Version.v251] = new string[]{"..."};
						validVersionCodes[HL7Version.v26] = new string[]{"..."};
						validVersionCodes[HL7Version.v27] = new string[]{"…"};
			
			// init the values for version descriptions
						validVersionDescriptions[HL7Version.v23] = new string[]{""};
						validVersionDescriptions[HL7Version.v231] = new string[]{"Military service related","Condition is employment related","Patient covered by insurance not reflected here","HMO enrollee","Lien has been filed","ESRD patient in first 18 months of entitlement covered by employer group health insurance","Treatment of non-terminal condition for hospice patient","Beneficiary would not provide information concerning other insurance coverage","Neither patient nor spouse is employed","Patient and/or spouse is employed but no EGHP exists","Disabled beneficiary but no LGHP","Payer codes.","Maiden name retained","Child retains mother’s name","Beneficiary requested billing","Billing for Denial Notice","VA eligible patient chooses to receive services in a medicare certified facility","Patient referred to a sole community hospital for a diagnostic laboratory test","Patient and/or spouse’s EGHP is secondary to Medicare","Disabled beneficiary and/or family member’s LGHP is secondary to Medicare","Patient is student (full time-day)","Patient is student (cooperative/work study program)","Patient is student (full time-night)","Patient is student (Part time)","General care patient in a special unit","Ward accommodation as patient request","Semi-private room not available","Private room medically necessary","Same day transfer","Partial hospitalization","Non-availability statement on file","Psychiatric residential treatment centers for children and adolescents","SNF bed not available","Medical appropriateness","SNF readmission","Day outlier","Cost outlier","Payer code","Provider does not wish cost outlier payment","Beneficiary elects not to use life time reserve (LTR) days","Beneficiary elects to use life time reserve (LTR) days","Self-administered EPO","Full care in unit","Self-care in unit","Self-care training","Home","Home - 100% reimbursement","Back-up in facility dialysis","Provider accepts or is obligated/required due to a contractual arrangement or law to accept payment by a primary payer as payment in full","New coverage not implemented by HMO","Corf services provided off-site","Pregnant"};
						validVersionDescriptions[HL7Version.v24] = new string[]{"Military service related","Condition is employment related","Patient covered by insurance not reflected here","HMO enrollee","Lien has been filed","ESRD patient in first 18 months of entitlement covered by employer group health insurance","Treatment of non-terminal condition for hospice patient","Beneficiary would not provide information concerning other insurance coverage","Neither patient nor spouse is employed","Patient and/or spouse is employed but no EGHP exists","Disabled beneficiary but no LGHP","Payer codes.","Maiden name retained","Child retains mother's name","Beneficiary requested billing","Billing for Denial Notice","VA eligible patient chooses to receive services in a Medicare certified facility","Patient referred to a sole community hospital for a diagnostic laboratory test","Patient and/or spouse's EGHP is secondary to Medicare","Disabled beneficiary and/or family member's LGHP is secondary to Medicare","Patient is student (full time-day)","Patient is student (cooperative/work study program)","Patient is student (full time-night)","Patient is student (Part time)","General care patient in a special unit","Ward accommodation as patient request","Semi-private room not available","Private room medically necessary","Same day transfer","Partial hospitalization","Non-availability statement on file","Psychiatric residential treatment centers for children and adolescents","SNF bed not available","Medical appropriateness","SNF readmission","Day outlier","Cost outlier","Payer code","Provider does not wish cost outlier payment","Beneficiary elects not to use life time reserve (LTR) days","Beneficiary elects to use life time reserve (LTR) days","Self-administered EPO","Full care in unit","Self-care in unit","Self-care training","Home","Home - 100% reimbursement","Back-up in facility dialysis","Provider accepts or is obligated/required due to a contractual arrangement or law to accept payment by a primary payer as payment in full","New coverage not implemented by HMO","Corf services provided off-site","Pregnant"};
						validVersionDescriptions[HL7Version.v25] = new string[]{""};
						validVersionDescriptions[HL7Version.v251] = new string[]{"No suggested values"};
						validVersionDescriptions[HL7Version.v26] = new string[]{"No suggested values"};
						validVersionDescriptions[HL7Version.v27] = new string[]{"No suggested values"};
			            

        }

        
        public override ValidationIssue[] RunRule(string name, object owningObject, object value)
        {
            //todo: check if the value is valid in the current version
            //if the value is not valid in the current version, add it as a validation issue


            return new ValidationIssue[0];
        }
    }
}
